import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Req,
} from '@nestjs/common';
import { CarService } from './car.service';

@Controller('car_web')
export class CarController {
  constructor(private readonly carService: CarService) {}

  // @Post()
  // create(@Body() createCarDto: CreateCarDto) {
  //   return this.carService.create(createCarDto);
  // }

  @Get('by_user_id')
  async findAll(@Req() request: any) {
    return await this.carService.findCarByUserId(request.managerInfo.sub);
  }

  @Post('/add_photo_car/:id')
  addCarPhotos(@Param('id') carId, @Req() request: any, @Body() params) {
    return this.carService.addCarPhotos(carId, params);
  }

  @Post('/add_car')
  addCar(@Req() request: any, @Body() params) {
    const userId = request.managerInfo.sub;
    return this.carService.addCar(userId, params);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.carService.findOne(+id);
  }

  // @Patch(':id')
  // update(@Param('id') id: string, @Body() updateCarDto: UpdateCarDto) {
  //   return this.carService.update(+id, updateCarDto);
  // }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.carService.remove(+id);
  }
}
